
///
/// zhaoliang
///
/// 防抖工具类
///
/// 2022.6.14
///
///
///

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

DateTime lastTime;
class UnQuickTap extends StatelessWidget {
  final Widget child;
  final GestureTapCallback myTap;
  const UnQuickTap({Key key,this.child,this.myTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: (){
        if(lastTime==null || DateTime.now().difference(lastTime)>Duration(seconds: 2)){
          myTap();
          lastTime=DateTime.now();
        }else{
          Fluttertoast.showToast(msg: '操作过于频繁');
        }
      },
      child: child,
    );
  }
}
